//
//  RHPlantInfoChartCell.m
//  RuiHeAppApp
//
//  Created by Jun on 2023/7/26.
//

#import "RHPlantInfoChartCell.h"
#import "RHPlantChartView.h"

@interface RHPlantInfoChartCell()

@property (nonatomic ,strong) RHPlantChartView *chartView;

@end

@implementation RHPlantInfoChartCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}
- (void)setChartModel:(DevChartModel *)chartModel{
    _chartModel = chartModel;

    [_chartView setChartModel:_chartModel];
}
- (void)setupUI{
    
    [self setBackgroundColor:UIColor.clearColor];
    [self.contentView setBackgroundColor:UIColor.clearColor];
    
    UIView *bgView = [[UIView alloc] init];
    [bgView setBackgroundColor:UIColor.whiteColor];
    [self.contentView addSubview:bgView];
    
    kWeakSelf;
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(0,15, 0, 15));
    }];
    
    _chartView = [[RHPlantChartView alloc] initWithFrame:CGRectMake(5, 5,SCREEN_WIDTH-40, 250+90) type:0];
    
    [bgView addSubview:_chartView];
    _chartView.fullChartBlock = ^{
        if (weakSelf.fullChartBlock) {
            weakSelf.fullChartBlock();
        }
    };
    _chartView.selectTopToolBlock = ^(NSInteger index) {
//        if (weakSelf.selectTopToolBlock) {
//            weakSelf.selectTopToolBlock(index);
//        }
    };
    
    _chartView.subTimeBlock = ^{//日期往前
//        if (weakSelf.subTimeBlock) {
//            weakSelf.subTimeBlock();
//        }
    };
    
    _chartView.addTimeBlock = ^{//日期往后
//        if (weakSelf.addTimeBlock) {
//            weakSelf.addTimeBlock();
//        }
    };
    
    _chartView.changeTimeBlock = ^{
//        if (weakSelf.changeTimeBlock) {
//            weakSelf.changeTimeBlock();
//        }
    };
    
    
    [_chartView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(5);
        make.right.mas_offset(-5);
        make.top.mas_offset(5);
        make.bottom.mas_offset(0);
        make.height.mas_equalTo(250+90);
    }];
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
